package edu.pw.treegrid.server.web.converters;

import edu.pw.treegrid.server.message.Path;
import edu.pw.treegrid.server.model.DomainField;
import edu.pw.treegrid.server.model.DomainObject;
import edu.pw.treegrid.server.web.ReportColumnDescriptionServer;
import edu.pw.treegrid.server.web.ReportController;
import xalan.smartgwt.record.BeanToRecordConverter;
import xalan.smartgwt.record.Record;

public class DomainObjectConverter implements
		BeanToRecordConverter<DomainObject> {

	@Override
	public void convert(Record r, DomainObject object) {
		Path path = object.getPath();
		Path parentPath = object.getParentPath();
		
		r.addParam(ReportColumnDescriptionServer.PATH_COLUMN, path.buildPathString());
		r.addParam(ReportColumnDescriptionServer.PARENT_PATH_COLUMN, parentPath.buildPathString());
		r.addParam(ReportColumnDescriptionServer.NAME_COLUMN, object.getName());
		r.addParam(ReportColumnDescriptionServer.IMAGE_SRC, object.getImageSrc());
		r.addParam(ReportColumnDescriptionServer.FOLDER_COLUMN, object.isFolder());
		
		for(DomainField df : object.getDomainField()) {
			r.addParam(df.getReportColumn().getName(), df.getValue());
		}
	}


}
